package vo

/**
0： 正常返回
500: 未知异常
300:普通业务异常
300～399，业务异常
700：未登陆，token校验异常
*/
type Result struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

func NotLogin() Result {
	return Result{Code: TokenInvalidCode, Message: "请登陆"}
}

func Success(data interface{}) Result {
	return Result{Code: 0, Message: "操作成功", Data: data}
}

func SuccessSimple() Result {
	return Result{Code: 0, Message: "操作成功"}
}

func Fail(code int, message string) Result {
	return Result{Code: code, Message: message}
}

func FailParamError() Result {
	return Result{Code: 300, Message: "参数异常"}
}

const (
	TokenInvalidCode = 700
	CurrentUserKey   = "CurrentUserKey"
)
